#include <iostream>
#include <cstring>
#define MAX_CHAR 1000

using namespace std;

int partition(int (&table)[MAX_CHAR + 1], int begin, int end){
	int i = begin;
	int j = end;
	int temp = table[begin];
	while(i < j){
		while( i < j && table[j] >= temp) j--;
		if(i < j) table[i] = table[j];
		while( i < j && table[i] <= temp) i++;
		if(i < j) table[j] = table[i];
	}
	table[i] = temp;
	return i;
}

void quickSort(int (&table)[MAX_CHAR+1], int begin, int end){
	if(begin < end){
		int p = partition(table, begin, end);
		quickSort(table, begin, p-1);
		quickSort(table, p+1, end);
	}
}


int main(){
	int n;
	cin >> n;
	int length;
	cin >> length;
	int table[MAX_CHAR + 1];
	for(int i = 1; i <= n; i++)
		cin >> table[i];
	quickSort(table, 1, length);
	int sum = 0;
	int result = 0;
	for(int i = 1; i <= n; i++){
		if(sum + table[i] <= length){
			sum += table[i];
			result++;
		} else break;
	}
	cout << result << endl;
}
